package com.pzc.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.query.Query;

import com.luojun.entity.User;
import com.luojun.util.HibernateUtil;
import com.pzc.db.DBUtil;
import com.pzc.entity.admin;

public class AdminDao {
	protected Connection conn;
	protected PreparedStatement preparedStatement;
	protected ResultSet rs;
	
	public boolean login(String adminname,String adminpassword) {
		Session session = null;
		Transaction transaction = null;
		admin admin = null;
			session = HibernateUtil.openSession();
			transaction = session.beginTransaction();
			 Query q = session.createQuery(" from admin a  where a.adminname = ? and a.adminpassword = ? ");
			 q.setString(0, adminname);
			 q.setString(1, adminpassword);

			 
			 transaction.commit();// 5.提交事务
			 
		
			 if(q.list().isEmpty()){ //只查看获得的数据list里的第一条数据（下表为0）
				return false;
			 }else{
				 return true;
			 }
	
}
}